<?PHP
namespace SDF\Core;

/**
 * 视图
 * @package SDF\Core
 */
class View {
    /**
     * @param array $data
     * @param string $tplFile
     * @throws \Exception
     */
    public static function display(array &$data = array(), $tplFile = '') {
        $tplPath = Config::getField('project', 'tpl_path', \SDF\SDF::getRootPath() . 'template' . DS . 'default' . DS);
        //$tplFile = \str_replace('\\',DS,$tplFile);
        //$tplFile = $tplFile==''?$GLOBALS['PARSE_INFO']['control'].DS.$GLOBALS['PARSE_INFO']['action']:$tplFile;
        $fileName = $tplPath . $tplFile . '.php';
        if (!\is_file($fileName)) {
            throw new \Exception("no file {$fileName}", 404);
        }else{
            if (!empty($data)) {
                \extract($data);
            }
            include $fileName;
        }

    }
}